package com.shop.cereshop.commons.tencent.im.enums.transfer;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @description: 转账订单状态枚举
 * @author zdd
 * @date 2025/9/3 11:27
 * @version 1.0
 */
public enum TransferOrderStatusEnum {

    // 转账订单状态: 1-待支付, 2-支付中, 3-待领取, 4-已完成, 5-已过期, 6-已退款, 7-支付失败
    PENDING_PAY(1, "待支付"),
    PAYMENT_IN_PROGRESS(2, "支付中"),
    PENDING_RECEIVED(3, "待领取"),
    COMPLETED(4, "已完成"),
    EXPIRED(5, "已过期"),
    REFUNDED(6, "已退款"),
    PAY_FAILED(7, "支付失败"),

    ;

    private final Integer code;
    private final String msg;

    private static final Map<Integer, TransferOrderStatusEnum> CODE_MAP = new HashMap<>();

    static {
        for (TransferOrderStatusEnum status : TransferOrderStatusEnum.values()) {
            CODE_MAP.put(status.getCode(), status);
        }
    }

    TransferOrderStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        TransferOrderStatusEnum status = CODE_MAP.get(code);
        return status != null ? status.getMsg() : "";
    }
}
